package handler

import org.paic.d.D

// 调试用
handler.get('/ibid/admin'){req, resp ->
	String sql = '''
create table if not exists t_ibid_card_user (
id int auto_increment primary key,
openid varchar(50),
company_id int,
dd timestamp default current_timestamp
);

create index idx_card_user_openid on t_ibid_card_user(openid);
create index idx_card_user_company_id on t_ibid_card_user(company_id);

create table if not exists t_ibid_card_company (
id int auto_increment primary key,
name varchar(100),
openid_manager varchar(50),
pwd varchar(50),
dd timestamp default current_timestamp
);

create index idx_card_company_openid_manager on t_ibid_card_company(openid_manager);

create table if not exists t_ibid_card_scaner (
id int auto_increment primary key,
name varchar(100),
company_id int,
status tinyint default 1,
token varchar(50)
);

create index idx_card_scaner_company_id on t_ibid_card_scaner(company_id);

create table if not exists t_ibid_card_record (
id int auto_increment primary key,
openid varchar(50),
scaner_id int,
company_id int,
dd timestamp default current_timestamp
);

create index idx_card_record_openid on t_ibid_card_record(openid);
create index idx_card_record_company_id on t_ibid_card_record(company_id);
	'''

	sql = '''
	create table if not exists t_ibid_leave_msg (
		id int auto_increment primary key,
		msg varchar,
		dd timestamp default current_timestamp
	);
	'''
	def dao = D.gen()
	try {
//		def ll = dao.query('select * from T_IBID_CARD_COMPANY')
//		resp.json ll

//		dao.exe(sql)
			
		def ll = dao.query('select * from T_IBID_CARD_USER')
		for(one in ll){
		}

		resp.end 'ok'
	}catch(ex){
		log.error(ex.message, ex)
		resp.end ex.message
	}
}